const mysql = require('mysql');

const pool = mysql.createPool({
    connectionLimit: 10,
    host: 'localhost',
    user: 'root',
    password: 'root',
    database: 'huawei'
});

// pool.query('select * from users', (err, results) => {
//     if (err) console.log(err);
//     console.log(results);
// });

function query(sql) {
    return new Promise((resolve, reject) => {
        pool.query(sql, (err, results) => {
            if (err) reject(err);
            resolve(results);
        });
    });
}

module.exports = query; // 导出模块